/**
 * Created by tanyichao on 2017/3/16.
 */
const state = {
    count: 1,
    demoScrollTop: 0,
    isLoading: false,
    isPositionValueText : '',
    isPositionValue : false,
    direction: 'forward'
}

const mutations = {
    updateCountStatus (state, payload) {
        state.count = payload.count
    },
    updateDemoPosition (state, payload) {
        state.demoScrollTop = payload.top
    },
    updateLoadingStatus (state, payload) {
        state.isLoading = payload.isLoading
    },
    updateDirection (state, payload) {
        state.direction = payload.direction
    },
    updateIsPositionValue (state, payload) {
        state.isPositionValue = payload.isPositionValue
    },
    updateIsPositionValueText (state, payload) {
        state.isPositionValueText = payload.isPositionValueText
    }
}
const actions = {
    updateCountStatus ({commit}) {
        var num = store.state.vux.count + 1
        commit({type: 'updateCountStatus', count: num})
    },
    updateDemoPosition ({commit}, top) {
        commit({type: 'updateDemoPosition', top: top})
    },
    updateIsPositionValue ({commit}, isPositionValue) {
        console.log("我来查看isPositionValue：" + isPositionValue)
        commit({type: 'updateIsPositionValue', isPositionValue: isPositionValue})
    },
    updateIsPositionValueText ({commit}, isPositionValueText) {
        if(isPositionValueText == "网络异常"){window.location.reload();}
        commit({type: 'updateIsPositionValueText', isPositionValueText: isPositionValueText})
    }
}

export default {
    state,
    actions,
    mutations
}
